package com.swfgui.utils.time
{
	import com.swfgui.interfaces.IDisposable;
	import com.swfgui.queue.WaitForMethod;
	import com.swfgui.queue.WaitForValue;
	

	public class WaitFor
	{
		public function WaitFor()
		{
		}
		
		/**
		 * 等待一个值为true
		 * @param owner
		 * @param propertyName
		 * @param onValueExist
		 * @param onValueExistArgs
		 * @param timeOut 超时秒数，0则无限等待
		 */
		public static function waitForValue(owner:Object, 
											propertyName:String, 
											onValueExist:Function, 
											onValueExistArgs:Array = null, 
											timeOut:Number=0):IDisposable
		{
			var w:WaitForValue = new WaitForValue();
			w.waitForValue(owner, propertyName, onValueExist, onValueExistArgs, timeOut);
			return w;
		}
		
		/**
		 * 等待一个函数返回true
		 * @param method
		 * @param onValueExist
		 * @param onValueExistArgs
		 * @param timeOut 超时秒数，0则无限等待
		 */
		public static function waitForMethod(method:Function, 
											onValueExist:Function, 
											onValueExistArgs:Array = null, 
											timeOut:Number=0):IDisposable
		{
			var w:WaitForMethod = new WaitForMethod();
			w.waitForMethod(method, onValueExist, onValueExistArgs, timeOut);
			return w;
		}
		
	}
}


